#!/usr/bin/env python3
# -*- coding:utf-8 -*-
from smtplib import SMTPResponseException

import zmail
from config.conf import settings
from utils import time_util
from utils.log_manager import my_logger

def send_report():
    """发送报告"""
    report_file = "E:\\report\html\\index.html"
    with open(report_file, encoding='utf-8') as f:
        content_html = f.read()
    try:
        mail = {
            'from': '2560955388@qq.com',
            'subject': '最新的测试报告邮件'+ time_util.get_now(),
            'content_html': content_html,
            'attachments': [report_file, ]
        }
        server = zmail.server(*settings.EMAIL_INFO.values())
        server.send_mail(settings.ADDRESSEE, mail)

    except SMTPResponseException as e:
        pass
    finally:
        print("测试邮件发送成功！")


if __name__ == "__main__":
    '''请先在config/conf.py文件设置QQ邮箱的账号和密码'''
    send_report()
